<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport"
	      content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">

	<title> ${category} Product Ranking on Instagram | GugeeData</title>
	<meta name="description" content="The ranking of the Instagram ${category} products who have the most engagements. | GugeeData">
	<meta name="keywords" content="Instagram Promote, Influencer Marketing, Instagram Marketing">
	<meta property="og:title" content="${category} Product Ranking on Instagram | GugeeData">
	<meta property="og:description" content="The ranking of the Instagram ${category} products who have the most engagements. | GugeeData">
	<meta property="og:type" content="website">
	<#if category == ''>
		<meta property="og:url" content="https://www.gugeedata.com/instagram/product-ranking">
	<#else>
		<meta property="og:url" content="https://www.gugeedata.com/instagram/${category}-product-ranking">
	</#if>
	<meta property="og:image" content=" https://seo-imags.s3.us-east-2.amazonaws.com/Logo.png">
	<meta name="twitter:title" content="${category} Product Ranking on Instagram | GugeeData">
	<meta name="twitter:description" content="The ranking of the Instagram ${category} products who have the most engagements. | GugeeData">

	<link rel="icon" href="${request.contextPath}/static/img/favicon.ico" type="image/x-icon"/>
	<link rel="shortcut icon" href="${request.contextPath}/static/img/favicon.ico" type="image/x-icon"/>
	<link href="https://fonts.googleapis.com/css2?family=Oswald:wght@500&display=swap" rel="stylesheet">
	<link rel="stylesheet" href="${request.contextPath}/static/plugins/layui/layui.css">
	<link rel="stylesheet" href="${request.contextPath}/static/css/ins/common.css">
	<link rel="stylesheet" href="${request.contextPath}/static/css/ins/rank.css">
	<link rel="stylesheet" href="${request.contextPath}/static/css/ins/product-rank.css">

    <#include "../../../component/facebookPixel.ftl">
</head>
<body>
<#include "../../../header_new1.ftl">
<main>
	<section>
		<div class="container">
			<h1>Instagram ${category} Product Ranking</h1>
			<h2>The ranking of the Instagram ${category} products who have the most engagements.</h2>
		</div>
	</section>
	<section>
		<div class="container is-pc">
			<div class="export-row">
				<div class="gd-btn-group">
<#--					<div class="gd-btn is-active">Daily</div>-->
					<div class="gd-btn is-active">Weekly</div>
					<div class="gd-btn">Monthly</div>
				</div>
				<div class="gd-select">
					<div class="gd-select-title">
						<div class="label"></div>
						<i class="iconfont icondown1"></i>
					</div>
					<div class="gd-select-wrap">
						<ul id="dateDayList" style="display: none"></ul>
						<ul id="dateWeekList"></ul>
						<ul id="dateMonthList" style="display: none"></ul>
					</div>
				</div>
				<button class="gd-btn btn-info" id="exportBtn">Export</button>
                <#setting datetime_format="MM-dd-yyyy HH:mm"/>
				<div class="flex-right">Data Updated： ${updateTime?number_to_datetime} UTC</div>
			</div>
			<div class="search-row">
				<div class="search-item" style="display: none">
					<div class="label">Product Category :</div>
					<div class="search-wrap">
						<ul id="categoryList">
							<li <#if category == ''>class="is-active"</#if>>All</li>
							<#list categories as item>
								<li <#if category == item.commercialCategory>class="is-active"</#if> value="${item.commercialCategory}">
                                    ${item.commercialCategory}
								</li>
							</#list>
						</ul>
					</div>
				</div>
			</div>
			<div class="tab-wrap">
				<table class="ins-table">
					<thead>
					<tr>
						<th width="120">Rank</th>
						<th align="left" width="500">Product Info</th>
						<th>
							<div class="gd-popover"
							     content="The number of creator partners who have tagged the product in their posts during the selected period.">
								Influencer
								<i class="iconfont iconfaq"></i>
							</div>
						</th>
						<th>
							<div class="gd-popover"
							     content="The number of ad posts that tagged the product during the selected period.">
								Post
								<i class="iconfont iconfaq"></i>
							</div>
						</th>
						<th>
							<div class="gd-popover"
							     content="Total comments and likes of the product ad posts during the selected period.">
								Engagements
								<i class="iconfont iconfaq"></i>
							</div>
						</th>
						<th>Action</th>
					</tr>
					</thead>
                    <#if listData.list?size gt 0>
	                    <tbody>
                        <#list listData.list as item>
							<tr>
								<td class="td-inx">
									<div class="td-inx__inner">
										<div class="tb-inx">${item.rank}</div>
									</div>
								</td>
								<td>
									<div class="td-product">
										<div class="cover">
                                            <#assign image=myController.getNoExpiredImage(item.image, 2, 1)>
											<img width="100" height="100" src="${image}" alt="product image">
										</div>
										<div class="media-info">
											<div class="title" title="${item.productName}">
												${item.productName}
											</div>
											<div class="sub-title-1">
												${item.price}
											</div>
											<div class="sub-title">
												<a href="/instagram/influencer/${item.username}">
                                                    <#assign picUrl=myController.getNoExpiredImage(item.picUrl, 0, 0)>
													<img width="24" height="24" src="${picUrl}" alt="image">
												</a>
												${item.username}
											</div>
										</div>
									</div>
								</td>
                                <#if item.influencerCount??>
                                    <#assign influencerCount=myController.getNumber(item.influencerCount)>
									<td>${influencerCount}</td>
                                <#else>
									<td>0</td>
                                </#if>
                                <#if item.mediaCount??>
                                    <#assign mediaCount=myController.getNumber(item.mediaCount)>
									<td>${mediaCount}</td>
                                <#else>
									<td>0</td>
                                </#if>
                                <#if item.tec??>
                                    <#assign tec=myController.getNumber(item.tec)>
									<td>${tec}</td>
                                <#else>
									<td>0</td>
                                </#if>
								<td>
									<div class="td-action">
										<div class="gd-popover" content="Analyze">
											<div class="blue">
												<a href="/instagram/product/${item.productId?c}" target="_blank">
													<i class="iconfont iconxiangqing"></i>
												</a>
											</div>
										</div>
									</div>
								</td>
							</tr>
                        </#list>
	                    </tbody>
                    <#else>
	                    <tbody>
							<tr>
								<td colspan="7">
									<div class="no-data">
										<img width="131" height="131" src="/static/img/ins/noData.png" alt="">
										<div class="title">No related data available</div>
									</div>
								</td>
							</tr>
						</tbody>
                    </#if>
				</table>
			</div>
			<div class="pagination" id="pagination"></div>
		</div>
		<div class="container is-mobile">
			<div class="sort-list">
				<div class="sort-item">
					Weekly
					<i class="iconfont icondown1"></i>
				</div>
				<div class="sort-item">
					<i class="iconfont icondown1"></i>
				</div>
				<div class="sort-item" style="display: none">
					<span class="label">Categories</span>
					<i class="iconfont icondown1"></i>
				</div>
			</div>
			<div class="filter-wrap">
				<div class="filter-wrap__inner">
					<div class="sort-list">
						<div class="sort-item">
							Weekly
							<i class="iconfont icondown1"></i>
						</div>
						<div class="sort-item">
							<i class="iconfont icondown1"></i>
						</div>
						<div class="sort-item" style="display: none">
							<span class="label">Categories</span>
							<i class="iconfont icondown1"></i>
						</div>
					</div>
					<ul id="sortDateType" style="display: none">
						<li style="display: block; padding: 0">
							<div class="gd-btn-select">
								<ul class="btn-select">
<#--									<li class="btn-select-item is-active" value="1">Daily</li>-->
									<li class="btn-select-item is-active" value="0" >Weekly</li>
									<li class="btn-select-item" value="1">Monthly</li>
								</ul>
							</div>
						</li>
					</ul>
					<ul id="sortDateDay" style="display: none"></ul>
					<ul id="sortDateWeek" style="display: none"></ul>
					<ul id="sortDateMonth" style="display: none"></ul>
					<ul id="sortCategory" style="display: none">
						<#if category == ''>
							<li class="is-active">
								All
								<div class="right"><i class="iconfont iconzhichi"></i></div>
							</li>
						<#else>
							<li>All</li>
						</#if>
                        <#list categories as item>
                            <#if category == item.commercialCategory>
	                            <li class="is-active" value="${item.commercialCategory}">
                                    ${item.commercialCategory}
		                            <div class="right"><i class="iconfont iconzhichi"></i></div>
	                            </li>
                            <#else>
	                            <li value="${item.commercialCategory}">
                                    ${item.commercialCategory}
	                            </li>
                            </#if>

                        </#list>
					</ul>
				</div>
			</div>
			<div class="tip-row">
				<div class="gd-popover"
				     content="<dl class='modal-tip'>
							<dt>1. Influencer</dt>
							<dd>The number of creator partners who have tagged the product in their posts during the selected period.</dd>
							<dt>2. Post</dt>
							<dd>The number of ad posts that tagged the product during the selected period.</dd>
							<dt>3. Engagements</dt>
							<dd>Total comments and likes of the product ad posts during the selected period.</dd>
						</dl>">
					Tip
					<i class="iconfont iconfaq"></i>
				</div>
			</div>
			<div class="gd-mobile-list">
				<div class="gd-mobile-list__wrap">
                    <#if listData.list?size gt 0 >
                        <#list listData.list as item>
							<a href="/instagram/product/${item.productId?c}">
								<div class="user-item">
									<div class="user-info">
										<div class="cover">
                                            <#assign image=myController.getNoExpiredImage(item.image, 2, 0)>
											<img width="80" height="80" src="${image}" alt="image">
										</div>
										<div class="user-title">
											<div class="top">
												<div class="title">${item.productName}</div>
											</div>
											<div class="bottom">${item.price}</div>
										</div>
										<div class="user-rank">
                                            ${item.rank}
										</div>
									</div>
									<div class="user-data">
										<div class="data-item">
											<div class="label">Influencer</div>
                                            <#if item.influencerCount??>
                                                <#assign influencerCount=myController.getNumber(item.influencerCount)>
												<div class="num">${influencerCount}</div>
                                            <#else>
												<div class="num">0</div>
                                            </#if>
										</div>
										<div class="data-item">
											<div class="label">Post</div>
                                            <#if item.mediaCount??>
                                                <#assign mediaCount=myController.getNumber(item.mediaCount)>
												<div class="num">${mediaCount}</div>
                                            <#else>
												<div class="num">0</div>
                                            </#if>
										</div>
										<div class="data-item">
											<div class="label">Engagements</div>
                                            <#if item.tec??>
                                                <#assign tec=myController.getNumber(item.tec)>
												<div class="num">${tec}</div>
                                            <#else>
												<div class="num">0</div>
                                            </#if>
										</div>
									</div>
								</div>
							</a>
                        </#list>
                    <#else>
						<div class="no-data">
							<img width="131" height="131" src="/static/img/ins/noData.png"
							     alt="no data"
							     srcset="/static/img/ins/noData@2x.png 2x, /static/img/ins/noData@3x.png 3x">
							<div class="title">No related data available</div>
						</div>
                    </#if>
				</div>
				<div class="gd-mobile-list__footer">
                    <#if login != false>
	                    <#if listData.list?size gt 0>
		                    <div class="rotate"><i class="iconfont icongengxin"></i></div>
		                    <span class="list-footer-tx" style="display: none">You have reached the end.</span>
	                    </#if>
                    <#else>
						<a href="#" class="link-login">
							View More
						</a>
                    </#if>
				</div>
			</div>
		</div>
	</section>
</main>
<#if isMobile == false>
    <#include "../../../footer_new.ftl">
	<script src="${request.contextPath}/static/plugins/layui/layui.js" charset="utf-8"></script>
</#if>
<script src="${request.contextPath}/static/js/gd-ui/button/group.js"></script>
<script src="${request.contextPath}/static/js/gd-ui/popover/index.js"></script>
<script src="${request.contextPath}/static/js/nums.js"></script>
<script src="${request.contextPath}/static/js/scroll.js"></script>
<script src="${request.contextPath}/static/js/list/common.js"></script>
<script>
    const params = {
        pageSize: 10,
        page: 1,
        rankType: 0,
        categoryName: '${category}'
    }
    let hasData = true
</script>
<script type="module">
    import { Select } from '/static/js/gd-ui/select/index.es.js'

    <#if isMobile == true>
    import { hideFilter } from '/static/js/list/mobile/common.js'
    import CONSTS from '/static/js/list/mobile/const.js'
    </#if>

    initRank()

    function initRank() {
        initOption()
        initEvent()
        <#if isMobile == false>
        initPagination()
        </#if>
    }

    function initOption() {
        _axios.get('/ins/product/rank/dates').then(res => {
            let str = ''
            if (res.Code === 200) {
                fgDate = res.Data
                if(gugeeGobal.isMobile) {
                    /* const sortDateDay = document.getElementById('sortDateDay')
					 res[1].Data.dailyDate.forEach((item, i) => {
						 if(i === 0) {
							 let title = item.dateDesc + '<i class="iconfont icondown1"></i>'
							 document.querySelectorAll('.is-mobile .sort-list .sort-item:nth-child(2)').forEach(item => {
								 item.innerHTML = title
							 })
							 params['date'] = item.dateCode
							 str += '<li data-label="' + item.dateDesc + '" value="' + item.dateCode + '" class="is-active">' +
								 item.dateDesc + '<div class="right"> <i class="iconfont iconzhichi"></i></div></li>'
						 } else {
							 str += '<li data-label="' + item.dateDesc + '" value="' + item.dateCode + '">' + item.dateDesc + '</li>'
						 }
					 })
					 sortDateDay.innerHTML = str*/

                    const sortDateWeek = document.getElementById('sortDateWeek')
                    str = ''
                    fgDate.weeklyDate.forEach((item, i) => {
                        if(i === 0) {
                            let title = item.dateDesc + '<i class="iconfont icondown1"></i>'
                            document.querySelectorAll('.is-mobile .sort-list .sort-item:nth-child(2)').forEach(item => {
                                item.innerHTML = title
                            })
                            params['date'] = item.dateCode
                            str += '<li data-label="' + item.dateDesc + '" value="' + item.dateCode + '" class="is-active">' +
                                item.dateDesc + '<div class="right"> <i class="iconfont iconzhichi"></i></div></li>'
                        } else {
                            str += '<li data-label="' + item.dateDesc + '" value="' + item.dateCode + '">' + item.dateDesc + '</li>'
                        }
                    })
                    sortDateWeek.innerHTML = str

                    const sortDateMonth = document.getElementById('sortDateMonth')
                    str = ''
                    fgDate.monthlyDate.forEach((item, i) => {
                        if(i === 0) {
                            str += '<li data-label="' + item.dateDesc + '" value="' + item.dateCode + '" class="is-active">' +
                                item.dateDesc + '<div class="right"> <i class="iconfont iconzhichi"></i></div></li>'
                        } else {
                            str += '<li data-label="' + item.dateDesc + '" value="' + item.dateCode + '">' + item.dateDesc + '</li>'
                        }
                    })
                    sortDateMonth.innerHTML = str
                    let gdMobileSelect = new Select()
                    <#if login == false>
                    gdMobileSelect.setBeforeSelectEvent(e => {
                        if(e.target.classList.contains('rank-tab-select')) {
                            return true
                        }
                        toLogin()
                        return false
                    })
                    </#if>
                    gdMobileSelect.init()
                } else {
                    /*const dateDayList = document.getElementById('dateDayList')
                    res[1].Data.dailyDate.forEach((item, i) => {
                        str += '<li value="' + item.dateCode + '"'
                        if(i === 0) {
                            str += ' class="is-active">' + item.dateDesc + '</li>'
                            dateDayList.parentElement.parentElement.querySelector('.label').innerText = item.dateDesc
                            params.date = item.dateCode
                        } else {
                            str += '>' + item.dateDesc + '</li>'
                        }
                    })
                    dateDayList.innerHTML = str*/

                    const dateWeekList = document.getElementById('dateWeekList')
                    str = ''
                    fgDate.weeklyDate.forEach((item,i) => {
                        str += '<li value="' + item.dateCode + '"'
                        if(i === 0) {
                            str += ' class="is-active">' + item.dateDesc + '</li>'
                            dateWeekList.parentElement.parentElement.querySelector('.label').innerText = item.dateDesc
                            params.date = item.dateCode
                        } else {
                            str += '>' + item.dateDesc + '</li>'
                        }
                    })
                    dateWeekList.innerHTML = str

                    const dateMonthList = document.getElementById('dateMonthList')
                    str = ''
                    fgDate.monthlyDate.forEach((item, i) => {
                        str += '<li value="' + item.dateCode + '"'
                        if(i === 0) {
                            str += ' class="is-active">' + item.dateDesc + '</li>'
                        } else {
                            str += '>' + item.dateDesc + '</li>'
                        }
                    })
                    dateMonthList.innerHTML = str

                    let gdSelect = new Select()
                    gdSelect.setElement(document.querySelectorAll('.export-row .gd-select'))
                    <#if login == false>
                    gdSelect.setBeforeSelectEvent(e => {
                        toLogin()
                        return false
                    })
                    </#if>
                    gdSelect.setSelectedEvent(e => {
                        const value = e.target.getAttribute('value')
                        params.page = 1
                        params.date = value
                        getRankList()
                    })
                    gdSelect.init()
                }
            }
            document.querySelectorAll('.filter-wrap__inner>ul>li').forEach(item => {
                item.addEventListener('click', e => {
                    if(!e.target.classList.contains('is-active')) {
                        params.page = 1
                        const ul = e.target.parentElement
                        const value = e.target.getAttribute('value')
                        const oldActive = ul.querySelector('.is-active')
                        oldActive.classList.remove('is-active')
                        e.target.classList.add('is-active')
                        oldActive.innerHTML = oldActive.innerText
                        if(ul.id === 'sortCategory') {
                            hideFilter()
	                        showLoading()
                            window.location.href = value ?'/instagram/' + value + '-product-ranking' :'/instagram/product-ranking'
                        } else {
                            params.date = value
                            e.target.innerHTML = e.target.getAttribute('data-label') + '<div class="right"> <i class="iconfont iconzhichi"></i></div>'
                            document.querySelectorAll('.sort-list .sort-item:nth-child(2)').forEach(sortItem => {
                                sortItem.innerHTML = e.target.getAttribute('data-label') + '<i class="iconfont icondown1"></i>'
                            })
                            hideFilter()
                            getMobileRankList()
                        }
                    }
                })
            })
        })
    }

    let fgDate = {}

    /** mobile **/
    let dateType = 0

    <#if isMobile == true>
	    <#if login == true>
	    let scrollTimer
	    window.addEventListener('scroll', () => {
	        if (!hasData) {
	            return
	        }
	        if (parseInt((getScrollTop() + getWindowHeight() + 200)) >= getScrollHeight()) {
	            if (scrollTimer) {
	                clearTimeout(scrollTimer)
	            }
	            scrollTimer = setTimeout(() => {
	                const list_len = document.querySelectorAll('.gd-mobile-list__wrap > a').length
	                if (list_len >= params.page * 10) {
	                    params.page++
	                    getMobileRankList()
	                }
	            }, 500)
	        } else {
	            if (scrollTimer) {
	                clearTimeout(scrollTimer)
	            }
	        }
	    })
	    </#if>
    <#else>
    let totalRow = +${listData.totalRow?c}
    </#if>

    function initEvent() {
        if(gugeeGobal.isMobile) {
            document.querySelectorAll('.gd-btn-select .btn-select-item').forEach(item => {
                item.addEventListener('click', e => {
                    if(!e.target.classList.contains('is-active')) {
                        params.page = 1
                        e.target.parentElement.querySelector('.is-active').classList.remove('is-active')
                        e.target.classList.add('is-active')
                        const ranType = +e.target.getAttribute('value')
                        if(params['rankType'] !== ranType) {
                            let str = ''
                            let dateName = ''
                            params['rankType'] = ranType
                            /*if(ranType === 1) {
								visitRecode(17)
								dateName = 'Daily'
								if(fgDate.dailyDate.length > 0) {
									params['date'] = fgDate.dailyDate[0].dateCode
									str = fgDate.dailyDate[0].dateDesc + '<i class="iconfont icondown1"></i>'
								} else {
									params['date'] = ''
								}
							} else */
                            if(ranType === 0) {
                                // visitRecode(18)
                                dateName = 'Weekly'
                                if(fgDate.weeklyDate.length > 0) {
                                    params['date'] = fgDate.weeklyDate[0].dateCode
                                    str = fgDate.weeklyDate[0].dateDesc + '<i class="iconfont icondown1"></i>'
                                } else {
                                    params['date'] = ''
                                }
                            } else {
                                // visitRecode(19)
                                dateName = 'Monthly'
                                if(fgDate.monthlyDate.length > 0) {
                                    params['date'] = fgDate.monthlyDate[0].dateCode
                                    str = fgDate.monthlyDate[0].dateDesc + '<i class="iconfont icondown1"></i>'
                                } else {
                                    params['date'] = ''
                                }
                            }
                            document.querySelectorAll('.sort-list .sort-item:nth-child(1)').forEach(item => {
                                item.innerHTML = dateName + '<i class="iconfont icondown1"></i>'
                            })
                            document.querySelectorAll('.sort-list .sort-item:nth-child(2)').forEach(item => {
                                item.innerHTML = str
                            })
                        }
                        hideFilter()
                        getMobileRankList()
                    }
                })
            })
	        document.querySelectorAll('.sort-list').forEach(sortList => {
				const items = sortList.querySelectorAll('.sort-item')
		        items.forEach((sortItem,i) => {
		            sortItem.addEventListener('click', () => {
		                showFilter(i)
		            })
		        })
	        })
        } else {
            const dateDayList = document.getElementById('dateDayList')
            const dateWeekList = document.getElementById('dateWeekList')
            const dateMonthList = document.getElementById('dateMonthList')
            const label = document.querySelector('.export-row .gd-select .label')
            document.querySelectorAll('.search-wrap li').forEach(item => {
                item.addEventListener('click', e => {
                    if(!gugeeGobal.isLogin) {
                        toLogin()
                        return false
                    }

                    if(!e.target.classList.contains('is-active')) {
                        const value = e.target.getAttribute('value')
                        window.location.href = value ?'/instagram/' + value + '-product-ranking' :'/instagram/product-ranking'
                    }
                })
            })
	        // 选择 周/月
            document.querySelectorAll('.gd-btn-group .gd-btn').forEach((item, i) => {
                item.addEventListener('click', e => {
                    if(!gugeeGobal.isLogin) {
                        toLogin()
                        return false
                    }

                    params.rankType = i
                    /*if(i === 0) {
						// visitRecode(17)
						if(fgDate.dailyDate.length > 0) {
							params['date'] = fgDate.dailyDate[0].dateCode
							label.innerText = fgDate.dailyDate[0].dateDesc
						} else {
							label.innerText = ''
							params['date'] = undefined
						}
						dateDayList.show()
						dateWeekList.hide()
						dateMonthList.hide()
					} else */
                    if(i === 0) {
                        // visitRecode(18)
                        if(fgDate.weeklyDate.length > 0) {
                            params['date'] = fgDate.weeklyDate[0].dateCode
                            label.innerText = fgDate.weeklyDate[0].dateDesc
                        } else {
                            label.innerText = ''
                            params['date'] = undefined
                        }
                        dateDayList.hide()
                        dateWeekList.show()
                        dateMonthList.hide()
                    } else {
                        // visitRecode(19)
                        if(fgDate.monthlyDate.length > 0) {
                            params['date'] = fgDate.monthlyDate[0].dateCode
                            label.innerText = fgDate.monthlyDate[0].dateDesc
                        } else {
                            label.innerText = ''
                            params['date'] = undefined
                        }
                        dateDayList.hide()
                        dateWeekList.hide()
                        dateMonthList.show()
                    }
                    params['page'] = 1
                    getRankList()
                })
            })
	        //导出
            document.getElementById('exportBtn').addEventListener('click', () => {
                exportRank()
            })
        }
    }

    function showFilter (type) {
        if(!gugeeGobal.isLogin) {
            toLogin()
            return false
        }

        document.body.style.overflow = 'hidden'
        document.body.style.position = 'fixed'
        const filterWrap = document.querySelector('.filter-wrap')
        filterWrap.style.top = getScroll().top + 60 + 'px'
        filterWrap.show()
        document.querySelectorAll('.filter-wrap__inner > ul').forEach(item => {
            item.hide()
        })
        const sortDateType = document.getElementById('sortDateType')
        const sortCategory = document.getElementById('sortCategory')
        if(type === 0) {
            sortDateType.show()
        } else if(type === 1) {
            /*if(params['rankType'] === 1) {
                document.getElementById('sortDateDay').show()
            } else */
            if(params.rankType === 0) {
                document.getElementById('sortDateWeek').show()
            } else {
                document.getElementById('sortDateMonth').show()
            }
        } else {
            sortCategory.show()
        }
    }

    function initPagination() {
        layui.use('laypage', function () {
            let laypage = layui.laypage;
            //执行一个laypage实例
            laypage.render({
                elem: 'pagination', //注意，这里的 test1 是 ID，不用加 # 号
                count: totalRow, //数据总数，从服务端得到
                prev: '<i class="iconfont iconicon_previous"></i>',
                next: '<i class="iconfont iconarrowright"></i>',
                jump: (obj, first) => {
                    if (!first) {
                        if(!gugeeGobal.isLogin) {
                            toLogin()
                            return false
                        }
                        params.page = obj.curr
                        getRankList()
                    }
                }
            })
        })
    }

    function getRankList() {
        if(params['categoryName'] === 'All') {
            params['categoryName'] = ''
        }
        let url = getEncodeUrl('/ins/product/rank', params)
        let tableBody = document.querySelector('.ins-table tbody')
        tableBody.showLoading()

        getList(tableBody, url, list => {
            let str = ''
            list.forEach(item => {
                str += '<tr>' +
                    '<td class="td-inx">' +
                    '<div class="td-inx__inner">' +
                    '<div class="tb-inx">' + item.rank + '</div>'
                str += '</div>' +
                    '</td>' +
                    '<td>' +
                    '<div class="td-product">' +
                    '<div class="cover">' +
                    '<img width="100" height="100" src="' + getImage(item.image, IMAGE_TYPE.PRODUCT, IMAGE_SIZE.MIDDLE) + '" alt="product image">' +
                    '</div>' +
                    '<div class="media-info">' +
                    '<div class="title" title="' + item.productName + '">' + item.productName +
                    '</div>' +
                    '<div class="sub-title-1">' + item.price +
                    '</div>' +
                    '<div class="sub-title">' +
                    '<a href="/instagram/influencer/' + item.username + '">' +
                    '<img width="24" height="24" src="' + item.picUrl + '" alt="image">' +
                    '</a>' + item.username +
                    '</div>' +
                    '</div>' +
                    '</div>' +
                    '</td>' +
                    '<td>' + numFormat(+item.influencerCount) + '</td>' +
                    '<td>' + numFormat(+item.mediaCount) + '</td>'+
                    '<td>' + numFormat(+item.tec) + '</td>'+
                    '<td>' +
                    '<div class="td-action">' +
                    '<div class="gd-popover" content="Analyze">' +
                    '<div class="blue">' +
                    '<a href="/instagram/product/' + item.productId + '" target="_blank">' +
                    '<i class="iconfont iconxiangqing"></i>' +
                    '</a>' +
                    '</div>' +
                    '</div>' +
                    '</div>' +
                    '</td>' +
                    '</tr>'
            })
            return str
        })
    }

    function getMobileRankList() {
        let url = getEncodeUrl('/ins/product/rank', params)
        const wrap = document.querySelector('.gd-mobile-list__wrap')
        wrap.showLoading()

        getList(wrap, url, list => {
            let str = ''
            list.forEach(item => {
                str += '<a href="/instagram/product/' + item.productId + '">' +
                    '<div class="user-item">' +
                    '<div class="user-info">' +
                    '<div class="cover">' +
                    '<img width="80" height="80" src="' + getImage(item.image, IMAGE_TYPE.PRODUCT, IMAGE_SIZE.SMALL) + '" alt="image">' +
                    '</div>' +
                    '<div class="user-title">' +
                    '<div class="top">' +
                    '<div class="title">' + item.productName + '</div>' +
                    '</div>' +
                    '<div class="bottom">' + item.price + '</div>' +
                    '</div>' +
                    '<div class="user-rank">' + item.rank + '</div>'
                str += '</div>' +
                    '<div class="user-data">' +
                    '<div class="data-item">' +
                    '<div class="label">Influencer</div>' +
                    '<div class="num">' + numFormat(+item.influencerCount) +'</div>' +
                    '</div>' +
                    '<div class="data-item">' +
                    '<div class="label">Post</div>' +
                    '<div class="num">' + numFormat(+item.mediaCount) + '</div>' +
                    '</div>' +
                    '<div class="data-item">' +
                    '<div class="label">Engagements</div>' +
                    '<div class="num">' + numFormat(+item.tec) +'</div>' +
                    '</div>' +
                    '</div>' +
                    '</div>' +
                    '</a>'
            })
            return str
        })
    }

    function exportRank() {
        if(!gugeeGobal.isLogin) {
            toLogin()
            return false
        }
        // visitRecode(20)
        const url = getEncodeUrl('/ins/product/rank/export', params)
        window.open(url)
    }
</script>
</body>
</html>